package week3;

import java.util.Scanner;

public class q2p {
    public static void main(String[] args) {
        int random = (int)(Math.random()*100);
        int guess = -1;
        int min = 0;
        int max = 100;
        Scanner sc = new Scanner(System.in);
        while(true){

            if(guess<min||guess>max){
                System.out.println("请输入一个"+min+"到"+max+"的数字");
                guess = sc.nextInt();
            }else if(guess==random){
                System.out.println("你猜对了!");
                break;
            }else if(guess<random){
                min = guess+1;
                System.out.println("小了");
            }else{
                max = guess-1;
                System.out.println("大了");
            }
        }
    }
}
